﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Easyleave.Logic.Domain;


namespace Easyleave.WinformsTestClient
{
    public partial class LeaveForm : Form
    {
        LeaveWorkflowServiceClient wofkflowClient;
        public UserDto User { get; set; }
        
        public LeaveForm()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            LeaveDto leaveDto = new LeaveDto();
            Guid instanceId = wofkflowClient.SubmitNewLeaveRequest(User.Id, leaveDto);
            this.textBox1.Text = instanceId.ToString();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            string state = wofkflowClient.RecommendLeaveRequest(new Guid(textBox1.Text), Guid.NewGuid(), textBoxMsg.Text);
            MessageBox.Show(state);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            string state = wofkflowClient.ApproveLeaveRequest(new Guid(textBox1.Text), Guid.NewGuid(), textBoxMsg2.Text);
            MessageBox.Show(state);
        }

        private void button4_Click(object sender, EventArgs e)
        {
            string state = wofkflowClient.RejectLeaveRequest(new Guid(textBox1.Text), Guid.NewGuid(), textBoxMsg2.Text);
            MessageBox.Show(state);
        }

        private void LeaveForm_Load(object sender, EventArgs e)
        {
            wofkflowClient = new LeaveWorkflowServiceClient("WSHttpBinding_ILeaveWorkflowService");
            this.textBox2.Text = User.Id.ToString().ToUpper();
        }
    }
}
